package com.zz.ecommerce.declareManage.changeDeclare;

import com.zz.ecommerce.common.bean.qdc.db.TDeclformHeadQdc;
import com.zz.ecommerce.common.constants.TableConstants;
import com.zz.ecommerce.declareManage.common.dao.QdcGoodsListDao;
import com.zz.ecommerce.declareManage.common.dao.TDeclformHeadQdcDao;
import com.zz.ecommerce.declareManage.common.dao.TWaybillHeadQdcDao;
import com.zz.ecommerce.declareManage.importB2CDeclareDirect.personalDeclMgnQdc.PersonalDeclDirectQdcDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by admin on 2016/3/30.
 */
@Service
public class ChangeDeclareService {


    @Autowired
    private TDeclformHeadQdcDao tDeclformHeadQdcDao;

    @Autowired
    private PersonalDeclDirectQdcDao personalDeclDirectQdcDao;

    @Autowired
    private QdcGoodsListDao qdcGoodsListDao;

    @Autowired
    private ChangeDeclareDao generateDeclareDao;

    @Autowired
    private TWaybillHeadQdcDao tWaybillHeadQdcDao;

    @Transactional(readOnly = false)
    public boolean changeDeclare(TDeclformHeadQdc tDeclformHeadQdc) {
        TDeclformHeadQdc query = tDeclformHeadQdcDao.query(TableConstants.T_DECLFORM_HEAD_QDC, tDeclformHeadQdc);

        TDeclformHeadQdc insertBean = new TDeclformHeadQdc();
        insertBean.setId(query.getId());
        insertBean.setReturnFlag("1");
        insertBean.setRelSeqNo(query.getSeqNo());
        insertBean.setRelWaybillId(query.getWaybillId());
        insertBean.setRelLogiEntecode(query.getLogiEnteCode());
        insertBean.setAppStepId("D");

        tDeclformHeadQdcDao.update(TableConstants.T_DECLFORM_HEAD_QDC, insertBean, "WHERE ID = '" + query.getId() + "'");
        personalDeclDirectQdcDao.declare(query.getId());
        return true;
    }
}
